﻿using Code_Group3.BUS;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Code_Group3.WEBFORM
{
    public partial class frmWithdraw : System.Web.UI.Page
    {
        string acc = "";
        Data.LogType logtype = new Data.LogType();
        Data.Log log = new Data.Log();
        Data.Card card = new Data.Card();
        BUS.LogBUS logBUS = new LogBUS();
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Page"] = "Withdraw.aspx";
            acc = Session["AccountID"].ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (AccountBUS.CheckWithdrawCard(acc, 100000))
            {
                AccountBUS.Withdraw(acc, 100000);
                //card.CARDID = Session["CardID"].ToString();
                //logtype.LOGTYPEID = 1;
                //log.AMOUNT = 100000;
                //log.DETAILS = " " + Session["NameCus"].ToString() + " rut tien";
                //logBUS.WriteLog(log,card,logtype);
                Response.Redirect("WithdrawContinue.aspx");
            }
            else
            {
                Session["Error"] = "1";
                Response.Redirect("Error.aspx");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (AccountBUS.CheckWithdrawCard(acc, 200000))
            {
                AccountBUS.Withdraw(acc, 200000);
                card.CARDID = Session["CardID"].ToString();
                logtype.LOGTYPEID = 1;
                log.AMOUNT = 200000;
                log.DETAILS = " " + Session["NameCus"].ToString() + " rut tien";
                logBUS.WriteLog(log, card, logtype);
                Response.Redirect("WithdrawContinue.aspx");
            }
            else
            {
                Session["Error"] = "1";
                Response.Redirect("Error.aspx");
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            if (AccountBUS.CheckWithdrawCard(acc, 500000))
            {
                AccountBUS.Withdraw(acc, 500000);
                card.CARDID = Session["CardID"].ToString();
                logtype.LOGTYPEID = 1;
                log.AMOUNT = 500000;
                log.DETAILS = " " + Session["NameCus"].ToString() + " rut tien";
                logBUS.WriteLog(log, card, logtype);
                Response.Redirect("WithdrawContinue.aspx");
            }
            else
            {
                Session["Error"] = "1";
                Response.Redirect("Error.aspx");
            }
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            if (AccountBUS.CheckWithdrawCard(acc, 1000000))
            {
                AccountBUS.Withdraw(acc, 1000000);
                card.CARDID = Session["CardID"].ToString();
                logtype.LOGTYPEID = 1;
                log.AMOUNT = 1000000;
                log.DETAILS = " " + Session["NameCus"].ToString() + " rut tien";
                logBUS.WriteLog(log, card, logtype);
                Response.Redirect("WithdrawContinue.aspx");
            }
            else
            {
                Session["Error"] = "1";
                Response.Redirect("Error.aspx");
            }
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            if (AccountBUS.CheckWithdrawCard(acc, 2000000))
            {
                AccountBUS.Withdraw(acc, 2000000);
                card.CARDID = Session["CardID"].ToString();
                logtype.LOGTYPEID = 1;
                log.AMOUNT = 2000000;
                log.DETAILS = " " + Session["NameCus"].ToString() + " rut tien";
                logBUS.WriteLog(log, card, logtype);
                Response.Redirect("WithdrawContinue.aspx");
            }
            else
            {
                Session["Error"] = "1";
                Response.Redirect("Error.aspx");
            }
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Response.Redirect("WithdralOtherMoney.aspx");
        }
    }
}